<include file="Public:js"/>
<style>
    img{display: block;}
    .button_iwant_buy{
        line-height: 1.4rem;
    }
</style>
<div class="page-group">
    <div class="page" data-page="index">
        <header class="bar bar-nav">
            <a onclick="goback()" class="icon" style="width: 40%">
                <img src="__PUBLIC__/img/iconfont_back@2x.png" class="back_img">
            </a>
            <button class="button button-link button-nav pull-right" onclick="window.location.href='{:U("Score/mallHistory")}'">
                兑换记录
            </button>
        </header>
        <div class="content infinite-scroll infinite-scroll-bottom" data-distance="100" style="text-align: center">
            <div class="row">
                <volist name="list" id="item">
                    <div class="col-50">
                        <div class="card">
                            <img src="{$item.logo}" alt="" width="100%">
                            <h4>所需积分{$item.price}</h4>
                            <div class="button_iwant_buy btn_radius" onclick="exchange({$item.product_id})">立刻兑换</div>
                        </div>
                    </div>
                </volist>
            </div>
            <!--<div style="color: #666">每月可兑换一次</div>-->
        </div>
    </div>
</div>
<script>
    $.config = {
        autoInit: true,
    }
    function exchange(product_id) {
        $.post("{:U('Score/makeExchange')}",{id:product_id},function(data){
            if(data.code){
                alert(data.msg);
            }else{
                alert(data.msg);
                location.reload();
            }
        });
    }
</script>